1. Field of the Invention
The present invention relates to a technique and method of processing a peripheral device. More particularly, the present invention relates to a data reading process for a disk drive and aims at the problem of the computer with an operating system that does not support disk drives. With the present invention, the drawback in the prior art that only a single sector is read can be avoided.
2. Description of the Related Art
Generally, an operating system (OS) is needed in a computer system for the starting operation of the computer and the driving services of all peripheral devices thereof. An example of Microsoft Windows OS series that is widely used, such as Windows NT, basically takes the disk drive as one of the standard peripherals of the computer system, and provides the driver for driving and accessing data of the disk drive. Therefore, the disk drive peripheral devices, such as hard disk drives or floppy disk drives, can be correctly used by calling proper routines through the application program interface (API). However, some well-known OS do not support the mechanical reading process of the disk drive. For example, the Windows CE OS, which is another product of Microsoft Windows OS series, is mainly used in the notepad computer, such as the personal digital agent (PDA), the handheld PC (HPC), and so on, instead of the ordinary desktop or notebook computer. Such an OS does not take the disk drive as one of the standard apparatus, and the disk drive is not supported therein. As a result, with such an OS, problems occur in the data reading process of a disk drive.
FIG. 1 is a flow chart showing the data reading process of a disk drive in the prior art, such as Windows CE OS. The parameters used therein are hereinafter described. The parameter TotalLength indicates the total length of data to be read from a disk drive. The parameter cbData indicates the length of data in each reading step. The parameter SectorSize indicates the length of a sector in the disk drive. The parameter ReadLength indicates the length of data that has been read and processed from the sector in current process. And, the parameter CurrentLength indicates the length of data that has been read and processed at present. All the parameters above indicate the length of data, and the same unit of measurement such as a byte can be introduced thereto. For example, the parameter SectorSize indicates the length of a single sector in bytes, such as 512 bytes in an ordinary sector. The parameter cbData indicates the length of data in bytes in each reading step, such as 32 bytes in length, which is usually smaller than the length of a single sector. And, the parameter TotalLength indicates the total length of data to be read in bytes, such as 2000 bytes.
Referred to FIG. 1, the OS first sets the parameters ReadLength and CurrentLength 0 (step S1), wherein the parameter ReadLength indicates length of data in a single sector while the parameter CurrentLength indicates length of data in all the sectors. A sector is then read from the disk drive with a reading subroutine (step S2). Notice that the prior art reads only a sector in each reading step. Then, in the previous read sector, data is processed in accordance with the length defined in the parameter cbData, and the parameters ReadLength and CurrentLength are both added by the parameter cbData (step S3). Then, the OS compares the parameter CurrentLength with the total length of data defined in the parameter TotalLength (step S4). If CurrentLength is not larger than TotalLength, the OS compares the parameter ReadLength with the length of a sector defined in the parameter SectorSize (step S5). If ReadLength is not larger than the SectorSize, the procedure flows back to step S3 to process the rest of the data of the previous read sector. On the other hand, if the parameter ReadLength is larger than the length of a sector, the parameter ReadLength is reset by subtracting the value of SectorSize from the former value of ReadLength (step S6), and the procedure flows back to step S2 for reading the next sector. The steps above are repeatedly executed until the parameter CurrentLength is larger than the total data length parameter TotalLength in step S4.
According to the above description, the system in the prior art reads only a sector in each reading step for the disk drive. However, in the practical reading operation, usually the total data is larger than a sector. As a result, in order to read all the sectors in sequence, the systems in the prior art must repeatedly turn on and off the disk drive intermittently. Such a method of reading data on a disk drive has many drawbacks. First, the operation time is wasted through repeatedly turning on and off the disk drive, thus the system performance is degraded. Furthermore, the repeatedly restarting of the driving motor of the disk drive causes harsh noise, electricity consumption to be increased, and the lifetime of the disk drive to be reduced.
Therefore, it is the main object of the present invention to provide a technique and a method for reading data on disk drives, especially for the OS that does not support the disk drive. The present invention does not repeatedly turn on and off the disk drive while reading thereof, so as to solve the problem in the prior art that only a single sector is read in a reading step.
According to the object above, the present invention discloses a method for reading data on a disk drive suited to a computer that does not support the disk drive hardware, such as the Microsoft Windows CE OS. First, the system allocates a free memory space in the computer memory. Then, the system reads data in a plurality of sectors of the disk drive and saves the data to the free memory space with a reading routine. While receiving a disk drive reading command, the system reads and processes the data of the disk drive saved in the free memory space in accordance with the disk drive reading command. Thus, the drawback of repeatedly turning on and off the disk drive is avoided while reading data with a length larger than a sector.
In addition, the present invention disclosed another method of reading data on a disk drive. Similarly, the system allocates a free memory space in the computer memory. Then, the system reads data in a plurality of sectors of the disk drive and saves the data to the free memory space with a reading routine. While receiving a disk drive reading command, the system sequentially reads and processes the data in response to a data processing length parameter in the data of the disk drive saved in the free memory space in accordance with the disk drive reading command and the data processing length parameter. A length corresponding to the data processing length parameter is smaller than a sector.
In the above method of the present invention, the disk drive may be a floppy disk drive with a floppy disk therein, or may be a hard disk drive. In addition, in the reading step, all the sector data in the floppy disk may be read and saved in the free memory space, wherein the length of the free memory space is larger than all sector data recorded in the floppy disk. Furthermore, the method can be used before the booting operation. The data may comprise booting parameters, and the operating system can be, for example, Windows CE OS. In order to save all the data of a floppy disk therein, the length of said free memory space is preferably in the range of 1 million to 2 millions bytes corresponding to the storage space of a common floppy disk.